#ifndef __SINGLETON_H__
#define __SINGLETON_H__
#include<iostream>
#include <string>
#include<mutex>

template<class T>
class Singleton{
public:
    static T* Instance(){
        static std::once_flag flag;
        std::call_once(flag,[&](){
            if(s_instance == nullptr)
            {
                s_instance = new T();
            }
        });
        return s_instance;
    }
     virtual ~Singleton() = default;
     Singleton(const Singleton&) = delete;
     Singleton& operator=(const Singleton&) = delete;
protected:
    Singleton()=default;
private:
    
    static T* s_instance;
};
template<class T>
T* Singleton<T>::s_instance = nullptr;



class SystemLaunch:public Singleton<SystemLaunch>
{
public:
    void dosomething(){
        std::cout<< "do somthing" << std::endl;
    }
    friend class Singleton<SystemLaunch>;
    SystemLaunch(const SystemLaunch&) =delete;
    SystemLaunch& operator=(const SystemLaunch&) = delete;
protected:
    SystemLaunch()=default;
};
#endif